package inet.db.tennis.buffer;

import java.math.BigDecimal;
import java.util.*;
import inet.db.tennis.*;

public class TennisSeasonBuffer {
	private static String object = "";
	
    private static Map seasonTable = new Hashtable(); //id - TennisSeason
    private static Vector seasonList = new Vector();

    public static Map getSeasonTable() {
    	synchronized(object) {
    		return seasonTable;
    	}
    }
    
    public static TennisSeason getSeason(BigDecimal id) {
    	synchronized(object) {
    		return (TennisSeason)seasonTable.get(id);
    	}
    }

    public static Vector getSeasonList() {
    	synchronized(object) {
    		return seasonList;
    	}
    }


    static {
        load();
    }

    public TennisSeasonBuffer() {
    }
    
    public static void reload(){
    	load();
    }
    
    private static void load() {
        TennisSeasonDAO seasonDAO = new TennisSeasonDAO();
        Collection c = seasonDAO.findAll();

        seasonList.addAll(c);

        TennisSeason season = null;
        for (Iterator it = c.iterator(); it.hasNext(); ) {
            season = (TennisSeason) it.next();
            if (season == null) continue;

            seasonTable.put(season.getId(), season);
        }
    }
}
